button.btn.btn-social.btn-google(onclick='googleLogin()') Google
script(type='text/javascript').
  /**
   * Get the value of a querystring
   * @param  {String} field The field to get the value of
   * @param  {String} url   The URL to get the value from (optional)
   * @return {String}       The field value
   */

  function googleLogin() {
    var clientId = '#{stormpathConfig.web.social.google.clientId}';
    var googleScope = '#{stormpathConfig.web.social.google.scope}';
    var hd = '#{stormpathConfig.web.social.google.hd}';

    var finalUrl = 'https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=' +
      clientId +
      '&scope=' + googleScope +
      '&include_granted_scopes=true&redirect_uri=' +
      '#{url}#{stormpathConfig.web.social.google.uri}';

    if (hd) {
      finalUrl = finalUrl + '&hd=' + hd;
    }

    window.location = finalUrl;
  }
